package com.bootemp.control;

import com.bootemp.bean.SalGrade;
import com.bootemp.service.SalgradeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("sal")
public class SalControl {
    @Resource
    public SalgradeService ss;
    @GetMapping(value = "/insert")
    public int insert(SalGrade s){
        return ss.insert(s);
    }
    @GetMapping(value = "/all")
    public List<SalGrade> all(){
        return  ss.all();
    }

    /**
     * 形参名与传递参数名不一致时，用请求参数注解
     * @param did
     * @return
     */
    @GetMapping(value = "/delete")
    public int delete(@RequestParam("id") int did){
        return ss.delete(did);
    }
    @PostMapping("/one")
    public SalGrade one(int id){
        return ss.one(id);
    }
    @GetMapping("/update")
    public int update(SalGrade s){
        return ss.update(s);
    }
    @GetMapping(value = "/page")
    public PageInfo<SalGrade> page(int cur){
        //设置当前页及长度
        PageHelper.startPage(cur,5);
        List<SalGrade> data=ss.all();
        return new PageInfo<>(data);
    }
}
